package com.ship.dispatch.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.ship.common.datasource.annotation.Slave;
import com.ship.dispatch.bean.SpInformation;
import com.ship.dispatch.bean.boats.QueryBoatsBaseRq;
import com.ship.dispatch.bean.boats.info.QueryBoatsPortSisterInfo;
import com.ship.dispatch.bean.boats.info.QueryShipMessageInfo;
import com.ship.dispatch.bean.treaShipNetwork.IhsShipBase;
import com.ship.dispatch.bean.treaShipNetwork.IhsShipBaseDetails;
import com.ship.dispatch.bean.treaShipNetwork.IhsShipBaseList;
import com.ship.dispatch.bean.treaShipNetwork.IhsShipBaseSelVo;
import com.ship.dispatch.vo.report.ShapeUnifyVo;
import com.ship.system.api.domain.dispatch.SimpleShipInfoVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SpInformationListMapper extends BaseMapper<IhsShipBaseList> {

    @Slave
    List<IhsShipBaseList> getListInfo();

    /**
     * 从静态表获取船名
     * @return
     */
    @Select("SELECT ship_name FROM ihs_ship_base")
    @Slave
    List<String> getShipNmae();

    /**
     * 从静态表获取imo
     * @return
     */
    @Select("SELECT imo FROM ihs_ship_base")
    @Slave
    List<String> getImo();

    /**
     * 从静态表获取船舶状态
     * @return
     */
    @Select("SELECT ship_status FROM ihs_ship_base")
    @Slave
    List<String> getShipStatusList();
    /**
     * 从静态表获取主机类型
     */
    @Select("SELECT main_engine_type FROM ihs_ship_base")
    @Slave
    List<String> getMainEngineTypeList();

    /**
     * 根据id获取列表信息 详情
     * @param id
     * @return
     */
    @Select("SELECT * FROM ihs_ship_base WHERE id = #{id} ")
    @Slave
    IhsShipBase getShipInfoById(@Param("id") Long id);

    /**
     * 获取列表所有内容
     * @return
     */
    @Select("SELECT * FROM ihs_ship_base ORDER BY ship_name")
    @Slave
    List<IhsShipBaseList> getInfo();

    /**
     * 根据id动态查询获取列表 导出用
     * @param ids
     * @return
     */
    @Select({
            "<script>",
            "SELECT * ",
            "FROM ihs_ship_base ",
            "WHERE imo IN ",
            "<foreach item='item' index='index' collection='arg0' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "ORDER BY ship_name",
            "</script>"
    })
    @Slave
    List<IhsShipBaseList> getInFOById(List<String> ids);

    @Select("SELECT COUNT(*) FROM ihs_ship_base")
    @Slave
    int getSize();

    @Slave
    List<IhsShipBaseList> queryShipList(@Param("query") IhsShipBaseSelVo query);

    @Slave
    IhsShipBase getShipInfoByImo(String imo);

    @Slave
    List<QueryBoatsPortSisterInfo> queryBoatsSister(@Param("query") QueryBoatsBaseRq query);

    @Slave
    List<QueryBoatsPortSisterInfo> queryBoatsSisterList(@Param("query") QueryBoatsBaseRq query);

    @Slave
    List<QueryShipMessageInfo> queryShipMessageAll(@Param("imoList") List<String> imoList);

    @Slave
    List<ShapeUnifyVo> queryTotalByShipStatus(@Param("startDate") String startDate,@Param("endDate") String endDate);

    List<ShapeUnifyVo> queryShipCount(@Param("startDate") String startDate,@Param("endDate") String endDate);

    ShapeUnifyVo queryShipCountLast();

    @Slave
    IhsShipBase queryShipByShipName(@Param("imo") String imo);

    @Slave
    void updateStatusByImo(@Param("imo") String imo);

    @Slave
    void updateStatusAll();


    Integer countShipNumber();

    @Slave
    List<SimpleShipInfoVo> getAllSimpleShipList();
}
